package cn.calm.swing.osgi.api.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cn.calm.swing.osgi.api.annotation.Id;
import cn.calm.swing.osgi.api.annotation.OneToMany;
import cn.calm.swing.osgi.api.annotation.Required;
import cn.calm.swing.osgi.api.annotation.Table;
@Table(name="PROJECT")
public class Project extends AbstractModelObject implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	private Long id;
	@Required(message="请输入项目名!")
	private String name;
	private String type;
	@OneToMany(mayBy = "project")
	private List<ProjectProperty> properties;

	public List<ProjectProperty> getProperties() {
		if(properties==null){
			properties=new ArrayList<ProjectProperty>();
		}
		return properties;
	}
	
	public void addProperties(ProjectProperty property){
		property.setProject(this);
		getProperties().add(property);
	}
	
	public void setProperties(List<ProjectProperty> properties) {
		this.properties = properties;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String oldValue = this.name;
		this.name = name;
		firePropertyChange("name", oldValue, this.name);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public String toString() {
		return "Project [id=" + id + ", name=" + name + ", properties="
				+ properties + "]";
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
